<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap-datetimepicker.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/picker.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/select2.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/beautify-time.css" type="text/css">
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.scss">
    <script src="${frames}/Chronic/laydate/laydate.js"></script>
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <%--<script src="${frames}/laydate/laydate.dev.js"></script>--%>
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>
    <script src="${newframe}/js/select2.full.zh.js"></script>
    <style>
        body{
            width:760px;
            overflow:hidden;
        }
        .test{
            width:100%;
            overflow:hidden;
        }
        .test p{
            width:100%;
            line-height:100px;
            font-size:15px;
            text-align:center;
        }
        #change{
            position:fixed;
            bottom:16px;
            right:16px;
        }
        label{
            margin-left:5px;
        }
        .text_number input{
            border:1px solid #d0d0d0;
            width:135px;
            height:30px;
        }
        .title{
            line-height:25px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
        }
        .title1{
            line-height:25px;
            font-size:15px;
            color:#666666;
            margin-left:17px;
            margin-top:5px;
        }
        .text_content{
            margin:20px 0;
            margin-left:18px;
        }
        .text_content div{
            width:48%;
            text-align: left;
            display: inline-block;
        }
        .text_number{
            color:#666666;
            margin-left:20px;
        }
        .bootstrapDatepickr-cal{
            top:465px !important;
        }
        #keep{
            background:#35acfd !important;
        }
        .change{
            position:fixed;
            top:60%;
            width:100%;
        }
        .btn{
            width:100px;
            line-height: 15px;
            background: #35acfd;
            color: white;
        }
        .modal-footer{
            width:255px;
            margin:0 auto;
        }
        img{
            max-width:100%;
            height:auto;
        }
        span{
            font-family: PingFang-SC-Regular;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #666666;
        }
        #szyValue{
            position:absolute;
        }
        .height_unit{
            position:relative;
            left:150px;
            border-left:1px solid #d0d0d0;
            width:40px;
            display:inline-block;
            text-align:center;
            line-height:30px;
        }
        #ssyValue{
            position:absolute;
        }
        #heartRate{
            position:absolute;
        }
        input{
            border: solid 1px #d0d0d0;
            width:210px !important;
            height:30px !important;
            vertical-align:middle;
            height:30px;
            display:inline-block !important;
        }
        .height_unit1{
            position:relative;
            left:165px;
            border-left:1px solid #d0d0d0;
            width:40px;
            display:inline-block;
            text-align:center;
            line-height:30px;
        }
        h1{
            font-family: MicrosoftYaHei;
            font-size: 20px;
            font-weight: normal;
            color: #2a3137;
            margin-bottom: 26px;
            float: left;
        }
        .defualt{
            border:1px solid red;
        }
    </style>
</head>
<body>
<div class="header">
    <h1>血压信息</h1>
</div>
<div class="test">
    <span style="width:5px;padding-bottom:25px;background-color:#35acfd;display:inline-block;vertical-align:middle"></span>
    <span class="title">最后一次血压检测</span>
    <div class="text_content">
        <div>
            <span style="width:20px;height:20px;display: inline-block;vertical-align:middle">
                <img src="../assets/images/ssy.png" alt="">
            </span>
            <span class="szyValue" style="margin-left:20px;">收缩压:</span>
            <input type="text" class="form-control" id="szyValue" onkeyup="value=value.replace(/[^\d]/g,'')">
            <span class="height_unit">mmHg</span>
        </div>
        <div>
            <span style="width:20px;height:20px;display: inline-block;vertical-align:middle">
                <img src="../assets/images/szy.png" alt="">
            </span>
            <span class="text_number">舒张压:</span>
            <input type="text" class="form-control" id="ssyValue" onkeyup="value=value.replace(/[^\d]/g,'')">
            <span class="height_unit">mmHg</span>
            </span>
        </div>
        <div style="margin-top:15px;">
            <span style="width:20px;height:20px;display: inline-block;vertical-align:middle">
                <img src="../assets/images/xl.png" alt="">
            </span>
            <span class="text_number">心率: </span>
            <input type="text" class="form-control" id="heartRate" onkeyup="value=value.replace(/[^\d]/g,'')" style="margin-left:14px;">
            <span class="height_unit1">bpm</span>
        </div>
        <div style="display:inline-block;margin-left:16px;">
            <span class="time">检验时间：</span>
            <div style="display:inline-block;width:210px;vertical-align:middle">
                <div class="times">
                    <div id="PrevTime" class="input-group date form_date" style="width: 100%"  data-date-format="yyyy-mm-dd">
                        <input id="beginDate" type="text" class="lay-date" readonly="readonly">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<div class="change">
    <div class="form-group submitBtn" style="text-align: center ">
        <button type="button" class="btn" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">
            关闭
        </button>
        <button type="submit" class="btn" id="keep"  onclick="keep()" style="margin-left:20px;">保存</button>
    </div>
</div>
<script>
    // 初始化
    var diseasesType = ''
    var url = ''
    var type = ""
    function initLayDate(id) {
        laydate({
            elem: id,
            istime: true,
            format: 'YYYY-MM-DD hh:mm:ss',
            choose: function (dates) { //选择好日期的回调
                // initTablePatient();
            }
        })
    }
    $(function(){
        initLayDate('#beginDate');
        var inputs = $('input')
        for( var a = 0; a < inputs.length; a++ ){
            $(inputs[a]).bind('change',function(){
                if( $(this).val() != '' ){
                    $(this).removeClass('defualt')
                }
            })
        }
        // 初始化获取当前时间
        var date=new Date();
        var year=date.getFullYear(); //获取当前年份
        var mon=date.getMonth()+1; //获取当前月份
        if( parseInt(mon) < 10 ){
            mon = '0' + mon
        }
        var da=date.getDate(); //获取当前日
        if( parseInt(da) < 10 ){
            da = '0' + da
        }
        var h=date.getHours(); //获取小时
        if( parseInt(h) < 10 ){
            h = '0' + h
        }
        var m=date.getMinutes(); //获取分钟
        if( parseInt(m) < 10 ){
            m = '0' + m
        }
        var s=date.getSeconds(); //获取秒
        if( parseInt(s) < 10 ){
            s = '0' + s
        }
        var d=document.getElementById('beginDate');
        d.value = year + '-' + mon + '-' + da + ' ' + h + ':' + m + ":" + s
        // 获取url 的idcard
        var href = location.search.split('?')[1]
        url = href.split('&')[0].split('=')[1]
        diseasesType = href.split('&')[1].split('=')[1]
        type = href.split('&')[2].split('=')[1]
    })
    //关闭并刷新
    function closeFrame() {
        window.parent.simpleCloseModal();
    }
    function keep(){
        // 获取数据
        var szyValue = $("#szyValue").val();
        var ssyValue = $("#ssyValue").val();
        var heartRate = $("#heartRate").val();
        if( szyValue === "" || ssyValue === "" || heartRate === "" ){
            var inputs = $('input')
            var arr = []
            for( var a = 0; a < inputs.length; a++ ){
                if( $(inputs[a]).val() === '' ){
                    $(inputs[a]).attr('placeholder','请输入数值')
                    $(inputs[a]).addClass('defualt')
                    arr.push($(inputs[a]))
                }
            }
            arr[0].focus()
            $(arr[0]).removeClass('defualt')
        }else{
            $.ajax({
                url:"${URL_PATIENT_ADDBPINFO}",
                dataType:"json",
                type:"post",
                data:{
                    idCard:url,
                    szyValue:ssyValue,
                    ssyValue:szyValue,
                    heartRate:parseInt(heartRate),
                    testTime:$('#beginDate').val()
                },
                success:function(data){
                    if( data.success ){
                        // 刷新当前页面
                        parent.showSrc('${URL_PATIENT_TOARCHIVES}?idCard=' + url +'&diseasesType='+ diseasesType+'&type='+type)
                        window.parent.simpleCloseModal();
                    }
                }
            })
        }
    }
</script>
</body>
</html>
